home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Development Platforms / Apple II / Essentials / GSBug / interactive Toolbox (text) < prev    next >
Encoding:
Text File  |  1991-08-06  |  7.2 KB  |  170 lines  |  [TEXT/MPS ]

  1. Exploring the Toolbox Interactively
  2. with GSBug and Nifty List
  3. by Dave Lyons, 15-Jul-91
  4.  
  5. An excellent way to get comfortable with the GS Toolbox is exploring
  6. it interactively.  For example, when you have a question about how a
  7. particular toolbox call behaves or when it is getting called, you can
  8. usually do a quick experiment to find out.
  9.  
  10. Techniques
  11.  
  12. *    Use GSBug and Nifty List together.  GSBug is great for taking
  13. control of the system when it executes particular toolbox calls or
  14. GS/OS calls, and Nifty List is great for examining the state of the
  15. system and making any toolbox calls you want "on the fly".
  16.  
  17. *    Explore the online help:  type "?" at the GSBug command line
  18. and at all the sub-screens.  Type "?" in Nifty List, and get help 
  19. for individual commands ("?_" for making toolbox calls, "?\" for 
  20. a list of all the "backslash" commands, "?\files", etc)
  21.  
  22. *    Use Nifty List as a toolbox quick-reference for tool sets, 
  23. functions within tool sets, and the parameters needed for each 
  24. function.
  25.  
  26. *    Experiment with making toolbox calls from the Nifty List
  27. command line; watch the results on the Super Hires screen.
  28.  
  29. *    Intercept tool calls being made by applications or other
  30. parts of the system.  Examine their results.  Modify the parameters
  31. before making the call, or create an "error" condition after the
  32. call.
  33.  
  34.  
  35. Exercises
  36.  
  37. These exercises demonstrate a moderate variety of GSBug and Nifty 
  38. List features.  Feel free to experiment...these are just ideas to
  39. get you started.
  40.  
  41. (Some of the exercisers assume your GS is running the Finder.)
  42.  
  43. Entering and exiting Nifty List
  44. Apple-Ctrl-Esc gets you to the CDA menu; move to Nifty List and hit
  45. Return.  When you want to leave Nifty List, Esc takes you back to 
  46. the CDA menu.
  47.  
  48. Entering and exiting GSBug
  49. Apple-Option-Ctrl-Esc gets you to GSBug.  "r Return" (for Resume)
  50. puts you back where you were.  While in GSBug, you can usually use
  51. Apple-Ctrl-Esc to get to CDAs, including Nifty List.  (In up-to-date
  52. GSBugs, the shortcut "n Return" also takes you to Nifty List.)
  53.  
  54. Step through code
  55. From GSBug, type "s Return" and hit Space a few times.  Each time 
  56. you hit Space, GSBug executes a single instruction, or a single
  57. toolbox call or GS/OS call.  You can watch the register contents 
  58. change at the top of the screen. -- Hit Esc to return to the command
  59. line, then "r Return" to leave GSBug.
  60.  
  61. Set a "Tool Break" or "OS Break"
  62. From GSBug, type "SetTBrk _NewWindow" and "TBRkIn" (to enable your
  63. toolbreak).  Resume and open a new window from the Finder.  You'll
  64. drop into GSBug when the Finder calls NewWindow (it hasn't executed
  65. yet).  Type "s Return".  Type "s" to see the SuperHires screen.  Hit
  66. Space to execute the NewWindow (the empty window appears).  Type "t"
  67. to return to the Text screen.  "Esc r Return" will let the Finder 
  68. continue full-speed.
  69.  
  70. OSBreaks work similarly.  Try "SetOSBrk _OpenGS" and "OSBrkIn", for 
  71. example.  (When you don't want your breaks any more, you'll want 
  72. TBrkOut and OSBrkOut.)
  73.  
  74. You may want to try tool-breaking on TaskMaster.  The Finder calls 
  75. TaskMaster in its main loop.  Lots of stuff can happen inside a 
  76. TaskMaster call (windows are drawn, moved, resized; menus are tracked).
  77. --  You may find it helpful after breaking on TaskMaster to press and
  78. hold the mouse somewhere (like on the menu bar), hit Space to execute
  79. TaskMaster, and do something with the mouse.  TaskMaster returns
  80. control to GSBug only when, say, you finally choose a menu item
  81. (or release the button without choosing one).  (After you're done,
  82. hit T to see the text screen.)
  83.  
  84. What Tool Sets are being used?  What functions do they contain?
  85. Enter Nifty List and type "v Return".  All loaded tool sets are
  86. listed (tool number, version, name, and other information).
  87.  
  88. To see all the functions in a particular tool set, type the tool
  89. set number followed by "T".  For example, "2t" for all the Memory
  90. Manager functions.  -- Most tool sets have more functions than fit
  91. on one screen, so use Space to freeze the screen and to advance by 
  92. one line.  Use Return to resume scrolling, and Esc or Apple-period 
  93. to return to the command line.
  94.  
  95. You can also get information on a single tool call, if you know its
  96. function number or part of its name.  For example, "902t" shows just
  97. information on NewHandle.  So does "NewH  (type the quote this time!).
  98.  
  99. Try "Paint to see all the toolbox functions containing "Paint" (most
  100. are in QuickDraw, but one is in Text Edit).  -- What is the difference
  101. between the "Paint" calls and the similar "Fill" calls?  (You may
  102. need to refer to Toolbox Reference, Volume 2; but with Nifty List
  103. you can quickly confirm the apparent pattern.)
  104.  
  105.  
  106. Make Some Toolbox Calls
  107. Still in Nifty List, type _TotalMem.  Nifty List makes the the call
  108. for you and displays the result.  (For a more verbose display of the
  109. result, put a ` in front of it:  `_TotalMem.)  More easy ones:  
  110. _SysBeep  _GrafOn, _GrafOff, _QDStatus, _QDVersion, _Random.
  111.  
  112. How about a call that needs some input parameter?  Integer Math? 
  113. Type "integer to find that it's tool set number B.  Type "bt" to see
  114. what calls are there.  --  Multiply probably scrolled off...type 
  115. "90bt" to see its parameters.  It needs two inputs, so type 
  116. _multiply(3,3) to get 9.
  117.  
  118. Int2Dec converts an integer into a decimal string.  It needs a place
  119. to put the result, and the memory from $00/0300 to $00/03BF is a good
  120. place to play with (good for people, not for programs).  -- Try 
  121. "int2dec to see the parameters, then (say) _Int2Dec(100,300,10,0).
  122. Then type 300.30f;h to see what it put in memory at location 300.
  123.  
  124. (If you want other scratch space, you can always call NewHandle
  125. manually, or you can use the \getdp or \getmem commands.)
  126.  
  127. _GetNewID(1000) allocates a new memory ID in the $10xx range and
  128. gives you the result.  What if you try something the toolbox
  129. considers "illegal", like asking for a memory ID in the "toolbox"
  130. range?  Try it:  _GetNewID(4000)
  131.  
  132. Sometimes it's handy to use the result of one toolbox call as a 
  133. parameter to another one.  No problem!  
  134.  
  135. What handles are allocated in memory, and who owns them?
  136. Type 0i to get a long(!) list of handles, addresses, sizes, owners,
  137. and owner names.  The zero means "everybody"--you can cut down the 
  138. list by typing a more limiting "user ID".  Try ?i for help with the 
  139. i command.
  140.  
  141. If you just want to see what memory IDs are who, try \ids.
  142.  
  143. Try a000i to see all handles owned by "init" files in your system;
  144. 5000i to see Desk Accessory handles ("?i" for a list of the memory
  145. ID ranges).
  146.  
  147. Disassemble some assembly code
  148. Try FF1800L to see a disassembly with a few toolbox calls in it.
  149.  
  150. How about E1/0L to see a lot of system Jump vectors and where they
  151. jump to?  Follow one and see what it does, or who it's jumping
  152. into (the "w" command is helpful).  There's more than just one
  153. screenful of these vectors (type L again).
  154.  
  155. Who is using the Resource Manager?
  156. Type \res to find out the IDs of all the things that have started 
  157. the Resource Manager (and the addresses of their Resource Converters,
  158. if any).  You'll probably find 401E (the Resource Manager itself),
  159. 1001 or 1002 (the Finder), and possibly more, especially if you have
  160. an NDA like the Control Panel open.
  161.  
  162. Keep exploring....
  163. See if you know how to use all the features listed on the Quick
  164. Reference pages.
  165.  
  166. See if you can use all the "backslash" commands listed by ?\
  167.  
  168. See if you can use all the toolbox calls!
  169.  
  170.